

let fs = require("fs")
let readline = require("readline")

let r1 = readline.createInterface({
    // input: fs.createReadStream("F:/st/steamapps/common/7 Days To Die/Data/Config/Localization.txt")
    input: fs.createReadStream("./Localization_jz_cn.txt")
})
let strs = {}

r1.on("line", (line) => {
    let tmp = findCn(line)
    if(tmp[17] != "") {
        strs[tmp[0]] = {
            en: tmp[5],
            cn: tmp[6]
        }
    }
})







r1.on("close", () => {
    fs.writeFileSync("./Localization_jz.js", "module.exports = " + JSON.stringify(strs))
})

function findCn(str) {
    let arr = str.split(",")
    let ret = [];
    
    
    let mode = false;
    let s = ""
    arr.forEach(v => {
      if(/^"/.test(v)) {
        mode = true;
        s = ""
      }
      if(/"$/.test(v)) {
        mode = false
        ret.push(s)
        return
      }
      if(mode) {
        s += v;
      } else {
        ret.push(v)
      }
    });
    return ret
  }
  

